/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package com.farent.solutions.plugins.stripes.hyperstripes.core;
import java.util.List;
import javax.xml.stream.XMLStreamReader;

/**
 * Represents an Element in the Component tree of a Hyperstripes page
 * @author farouka
 */
public interface ComponentModel
{
    /**
     * Adds a @{@link ComponentModel} to the list @{@link ComponentModel}s for which
     * this @{@link ComponentModel} is a parent
     * @param child
     */
    void AddChild( ComponentModel child );

    /**
     * Adds an attribute to this @{@link ComponentModel}
     * @param attribute the attribute to adds
     */
    void addAttribute( Attribute attribute );

    /**
     *
     * @return the attributes of this component at the time of call
     */
    List<Attribute> getAttributes();

    /**
     *
     * @return the list of @{@link ComponentModel}s for which
     * this @{@link ComponentModel} is a parent
     */
    List<ComponentModel> getChildren();

    /**
     *
     * @return the first ComponentModel in the list of children in this ComponentModel
     */
    ComponentModel getFirstChild();

    /**
     *
     * @return the last ComponentModel in the list of children in this ComponentModel
     */
    ComponentModel getLastChild();

    /**
     *
     * @return the Child in this component tree with the given id
     */
    ComponentModel getChild(String childId);

    /**
     *
     * @return the Attribute of this component tree with the given name
     */
    Attribute getAttribute(String attributeName);

    /**
     *
     * @return the first Attribute in the list of attributes in this ComponentModel
     */
    Attribute getFirstAttribute();

    /**
     *
     * @return the last Attribute in the list of attributes in this ComponentModel
     */
    Attribute getLastAttribute();

    /**
     * The unique Identifier that uniquely identifies this 
     * component in the component tree. This Id must be unique accross the whole view tree
     * @return
     */
    String getId();

    /**
     *
     * @return the name of this component as represented in the markup
     */
    String getName();

    /**
     * The text content of this component in the View description Language
     * @return
     */
    String getText();

    /**
     * The unique Identifier that uniquely identifies this
     * component in the component tree. This Id must be unique accross the whole view tree
     * @param the id to set
     */
    void setId( String id );

    /**
     *
     * @return the UniqueID of this component in the context of its direct parent
     */
    String getComponentId();

    /**
     * Sets the UniqueID of this component in the context of its direct parent
     * @param componentId
     */
    void setComponentId(String componentId) ;

    /**
     *
     * @param name the name of the component in the  VDL
     */
    void setName( String name );

    /**
     * Set the direct parent of this component in the component heirarchy
     * @param parent
     */
    void setParent( ComponentModel parent );

    /**
     * get the parent of this component in the component tree or null if none
     * @return
     */
    ComponentModel getParent();

    /**
     * Set the text content of this component
     * @param text
     */
    void setText( String text );

    /**
     * Is the provided component a child of this component
     * @param child
     * @return
     */
    boolean isChild(  ComponentModel child );

    /**
     * processes the tag as discovered by the Parser
     * @param streamReader
     */
    void processTag( XMLStreamReader streamReader );

    /**
     * Allows the component to create its own component id. Every component MUST
     * have an ID
     * @param seed ID attribute as found in the markup. May be null if not defined
     */
    String createUniqueId( String seed );

    /**
     * Allows the component to create an Id based on its parentId
     */
    String createComponentId( ComponentModel seed );

    /**
     * Sets the @{@link ComponentTypeStateHelper} that provides the
     * state of this component type in the modelTree. There is only one for each componentType
     * @param modelState
     */
    void setComponentTypeStateHelper( ComponentTypeStateHelper modelState );

    /**
     * Returns the @{@link ComponentTypeStateHelper} associated with this component
     */
    ComponentTypeStateHelper getComponentTypeStateHelper( );
}
